<template>
    <div class="components-container">
        <!-- 新增修改 -->
        <sweet-modal ref="dialog" class="dialog" :sweetModalMaxWidth="maxWidth" v-bind:blocking="true">
            <h3>{{title}}</h3>
            <div>
                <fieldset class="layui-elem-field layui-field-title">
                    <legend>基本信息</legend>
                </fieldset>
                <div style="margin:10px 50px;">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">逝者姓名</label>
                            <div class="layui-input-inline">
                                <el-input type="text" v-model="prpData.PRPDEADNAME" @blur="NameBlur(prpData.PRPDEADNAME)"></el-input>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">逝者年龄</label>
                            <div class="layui-input-inline">
                                <!-- <el-input-number v-model="prpData.PRPDEADAGE" :min="0"></el-input-number> -->
                                <el-input @keyup.native="check(prpData.PRPDEADAGE)"  type="text" v-model="prpData.PRPDEADAGE"></el-input>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">逝者性别</label>
                            <div class="layui-input-inline">
                                <el-select v-model="prpData.PRPDEADSEX" filterable :filter-method="chaFilter">
                                    <el-option v-for="item in sexType" :key="item.CodeValue" :label="item.CodeName" :value="item.CodeValue">
                                    </el-option>
                                </el-select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">接尸时间</label>
                            <div class="layui-input-inline chooseTime">
                                <el-date-picker style="width:115px;float:left;" clear-icon="null" type="date" v-date v-model="prpData.PRPWORKDATE"></el-date-picker>
                                <el-time-picker ref="choosetime" style="width:75px;float:left" :default-value="timeDefaultShow" clear-icon="null" v-date v-model="prpData.PRPWORKTIME" format='HH:mm'></el-time-picker>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">接尸地点</label>
                            <div class="layui-input-inline">
                                <el-select v-model="prpData.PRPADDID" @visible-change="selectAddr" filterable :filter-method="PinyinMatch">
                                    <el-option v-for="item in commonAddr" :key="item.CodeValue" :label="item.CodeName" :value="item.CodeValue"></el-option>
                                </el-select>
                            </div>
                            <div class="layui-input-inline">
                                <el-input type="text" v-model="prpData.PRPCORPSEADDRESS" style="width:280px"></el-input>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">死亡日期</label>
                            <div class="layui-input-inline chooseTime">
                                <el-date-picker type="date" v-date v-model="prpData.PRPDEATHDATE"></el-date-picker>
                            </div>

                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">死亡原因</label>
                            <div class="layui-input-inline backcolor">
                                <el-cascader :options="cause" v-model="cauinfo" filterable>
                                </el-cascader>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">来电日期</label>
                            <div class="layui-input-inline chooseTime">
                                <el-date-picker type="date" v-date v-model="prpData.PRPCALLDATE"></el-date-picker>
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">业务类别</label>
                            <div class="layui-input-inline">
                                <el-select v-model="prpData.PRPYITIQX">
                                    <el-option :key="item.CodeValue" :label="item.CodeName" :value="item.CodeValue" v-for="item in serviceListType"></el-option>
                                </el-select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">接运类别</label>
                            <div class="layui-input-inline">
                                <el-select v-model="prpData.PRPFEEDERCATEGORY">
                                    <el-option label="不选择" :value="null"></el-option>
                                    <el-option v-for="item in feeders" :key="item.value" :label="item.CodeName" :value="item.CodeName">
                                    </el-option>
                                </el-select>
                            </div>
                        </div>
                        <div class="layui-inline" v-if="!isShowyy">
                            <label class="layui-form-label">处理单位</label>
                            <div class="layui-input-inline">
                                <el-input type="text" v-model="prpData.PRPPROCESSINGUNIT"></el-input>
                            </div>
                        </div>
                        <div class="layui-inline" v-if="isShowyy">
                            <label class="layui-form-label" style="text-align:center;padding:0;">死亡证明部门</label>
                            <div class="layui-input-inline">
                                <el-input type="text" v-model="prpData.PRPPROCESSINGUNIT"></el-input>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">联系人1</label>
                            <div class="layui-input-inline">
                                <el-input type="text" v-model="prpData.PRPLINKMAN"></el-input>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">联系电话</label>
                            <div class="layui-input-inline">
                                <el-input type="text" v-model="prpData.PRPLINKPHONE"></el-input>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">逝者关系</label>
                            <div class="layui-input-inline">
                            <el-select v-model="prpData.PRPRELATION" editable="true" filterable allow-create default-first-option>
                                <el-option v-for="item in REGRELATIONOptions" :key="item.value" :label="item.label" :value="item.value">
                                </el-option>
                            </el-select>
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">联系人2</label>
                            <div class="layui-input-inline">
                                <el-input type="text" v-model="prpData.PRPSPARELINKMAN"></el-input>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">联系电话</label>
                            <div class="layui-input-inline">
                                <el-input type="text" v-model="prpData.PRPSPARELINKPHONE"></el-input>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">原始来电</label>
                            <div class="layui-input-inline">
                                <el-input type="text" v-model="prpData.PRPORIGINALCALL"></el-input>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item" v-if="isshowcar">
                        <div class="layui-inline">
                            <label class="layui-form-label">车辆类型</label>
                            <div class="layui-input-inline">
                                <el-select v-model="cdhcartype" filterable @change="pickupcardata($event)">
                                    <el-option v-for="item in carLics" :key="item.value" :label="item.label" :value="item.label">
                                    </el-option>
                                </el-select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">接运车辆</label>
                            <div class="layui-input-inline" ref="pickupcars">
                                <el-select v-model="pickupcar" filterable @change="dirverchange($event)">
                                    <el-option v-for="item in pickupcardatas" :key="item.Value" :label="item.label" :value="item.label">
                                    </el-option>
                                </el-select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">驾驶员</label>
                            <div class="layui-input-inline">
                                <el-select v-model="prpData.Cdh.CDHDRIVER">
                                    <el-option label="不选择" :value="null"></el-option>
                                        <el-option v-for="item in drivers" :key="item.value" :label="item.label" :value="item.value">
                                    </el-option>
                                </el-select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item" v-if="isshowone">
                        <div class="layui-inline">
                            <label class="layui-form-label">是否抬尸</label>
                            <div class="layui-input-inline">
                                <el-select v-model="prpData.PRPISLIFTUP" filterable>
                                    <el-option label="抬尸" value="1"></el-option>
                                    <el-option label="不抬尸" value="0"></el-option>
                                </el-select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">接运员</label>
                            <div class="layui-input-inline">
                                <el-select v-model="collectMember" placeholder="接运员" multiple>
                                    <el-option v-for="item in carriers" :key="item.value" :label="item.label" :value="item.value"></el-option>
                                </el-select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">是否特尸</label>
                            <div class="layui-input-inline">
                                <el-select v-model="prpData.PRPISSPECIAL" filterable>
                                    <el-option label="特尸" value="1"></el-option>
                                    <el-option label="非特尸" value="0"></el-option>
                                </el-select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item" v-if="isshowtwo">
                        <div class="layui-inline">
                            <label class="layui-form-label">是否带棺</label>
                            <div class="layui-input-inline">
                                <el-select v-model="prpData.PRPISCOFFIN" filterable>
                                    <el-option v-for="item in isdg" :key="item.Value" :label="item.Text" :value="item.Value">
                                    </el-option>
                                </el-select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">是否加班</label>
                            <div class="layui-input-inline">
                                <el-select v-model="prpData.Cdh.CDHISWORKOVERTIME" filterable>
                                    <el-option label="加班" value="1"></el-option>
                                    <el-option label="不加班" value="0"></el-option>
                                </el-select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">是否值班</label>
                            <div class="layui-input-inline">
                                <el-select v-model="prpData.Cdh.CDHISCHARGE" filterable>
                                    <el-option label="值班" value="1"></el-option>
                                    <el-option label="非值班" value="0"></el-option>
                                </el-select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline" v-if="isshowthree">
                            <label class="layui-form-label">火化炉</label>
                            <div class="layui-input-inline">
                                <el-select v-model="prpData.PRPCREMATION" filterable>
                                    <el-option v-for="item in hhldata" :key="item.Value" :label="item.Text" :value="item.Value">
                                    </el-option>
                                </el-select>
                            </div>
                        </div>
                        <div class="layui-inline" v-if="isshowthree">
                            <label class="layui-form-label" style="text-align:center;padding:0;">预约火化日期</label>
                            <div class="layui-input-inline chooseTime">
                                <el-date-picker style="width:115px;float:left;" clear-icon="null" type="date" v-date v-model="prpData.PRPCREMATIONDATE"></el-date-picker>
                                <el-time-picker ref="choosetime" :default-value="timeDefaultShow" style="width:75px;float:left" clear-icon="null" v-date v-model="prpData.PRPCREMATIONTIME" format='HH:mm'></el-time-picker>
                            </div>
                        </div>
                        <div class="layui-inline" v-if="isshowfour">
                            <label class="layui-form-label" style="text-align:center;padding:0;">是否出具死亡证明</label>
                            <div class="layui-input-inline">
                                <el-select v-model="prpData.PRPISPOD" filterable>
                                    <el-option v-for="item in choosearray" :key="item.Value" :label="item.Text" :value="item.Value">
                                    </el-option>
                                </el-select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">备注</label>
                            <div class="layui-input-inline">
                                <el-input style="width:770px" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入内容" v-model="prpData.PRPDESCRIBE">
                                </el-input>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                    </div>
                </div>
                <fieldset class="layui-elem-field layui-field-title" v-if="false">
                    <legend>服务项目</legend>
                </fieldset>
                <div class="layui-form-item" style="padding-left:130px" v-if="false">
                    <el-checkbox-group v-model="checkedItem" @change="ServiceItemsChange">
                        <el-checkbox v-for="value in ServiceItemsList" :label="value.SITID" :key="value.SITID" @change="changItem($event,value)">{{value.SITNAME}}</el-checkbox>
                    </el-checkbox-group>
                </div>
            </div>
            <div class="layui-form-item btnCenter">
                <el-button type="primary" icon="el-icon-close" @click="closeDialog">取消</el-button>
                <!-- :disabled="isdisable" -->
                <el-button type="primary" icon="el-icon-tickets" :loading="this.$store.state.isloading" @click="Preservation" :disabled="isdisable" v-if="issendcar">保存</el-button>
                <el-button type="primary" icon="el-icon-check" :loading="this.$store.state.isloading" :disabled="isdisable" @click="submit">提交</el-button>
                <el-button type="primary" icon="el-icon-message" :loading="this.$store.state.isloading" @click="Gosendcar" v-if="issendcarone">派车登记</el-button>
                <el-button type="primary" icon="el-icon-message" :loading="this.$store.state.isloading" @click="pdfpaicar" v-if="issendcarone">打印派车单</el-button>
                <!-- <el-button type="primary" icon="el-icon-mobile-phone" :loading="this.$store.state.isloading" @click="Gosendcar" v-if="ispaicar">业务洽谈</el-button> -->
            </div>
        </sweet-modal>
        <!-- 详情 -->
        <sweet-modal ref="info" class="dialog" :sweetModalMaxWidth="maxWidth" v-bind:blocking="true">
            <h3>{{title}}</h3>
            <label>业务编号：{{prpData.PRPNO}}</label>
            <fieldset class="layui-elem-field layui-field-title">
                <legend>基本信息</legend>
            </fieldset>
            <div style="margin:10px 50px;">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">逝者姓名</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPDEADNAME" readonly></el-input>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">逝者年龄</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPDEADAGE" readonly></el-input>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">逝者性别</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPDEADSEXDESC" readonly></el-input>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">接尸时间</label>
                        <div class="layui-input-inline chooseTime">
                            <el-date-picker style="width:115px;float:left;" clear-icon="null" type="date" v-date v-model="prpData.PRPWORKDATE" readonly></el-date-picker>
                            <el-time-picker ref="choosetime" style="width:75px;float:left" clear-icon="null" v-date v-model="prpData.PRPWORKTIME" format='HH:mm' readonly></el-time-picker>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">接尸地点</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model=" prpData.PRPCORPSEADDRESS" style="width:280px"></el-input>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">业务类别</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPYITIQXDESC" readonly></el-input>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">接运类别</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPFEEDERCATEGORY" readonly></el-input>

                        </div>
                    </div>
                    <div class="layui-inline" v-if="!isShowyy">
                        <label class="layui-form-label">处理单位</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPPROCESSINGUNIT" readonly></el-input>
                        </div>
                    </div>
                    <div class="layui-inline" v-if="isShowyy">
                        <label class="layui-form-label" style="text-align:center;padding:0;">死亡证明部门</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPPROCESSINGUNIT" readonly></el-input>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">联系人1</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPLINKMAN" readonly></el-input>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">联系电话</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPLINKPHONE" readonly></el-input>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">逝者关系</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPRELATION" readonly></el-input>
                        </div>
                    </div>
                    <!-- <div class="layui-inline">
              <label class="layui-form-label">来电日期</label>
              <div class="layui-input-inline">
                <el-date-picker type="date" placeholder="选择日期" v-model="prpData.PRPCALLDATE" format="yyyy-MM-dd" readonly></el-date-picker>
              </div>
            </div> -->
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">联系人2</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPSPARELINKMAN" readonly></el-input>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">联系电话</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPSPARELINKPHONE" readonly></el-input>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">原始来电</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPORIGINALCALL" readonly></el-input>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">死亡原因</label>
                        <div class="layui-input-inline backcolor">
                            <el-cascader :options="cause" v-model="cauinfo" filterable disabled>
                            </el-cascader>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">死亡日期</label>
                        <div class="layui-input-inline chooseTime">
                            <el-date-picker type="date" v-date v-model="prpData.PRPDEATHDATE" readonly></el-date-picker>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">来电日期</label>
                        <div class="layui-input-inline chooseTime">
                            <el-date-picker type="date" v-date v-model="prpData.PRPCALLDATE" readonly></el-date-picker>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item" v-if="isshowcar">
                    <div class="layui-inline">
                        <label class="layui-form-label">车辆类型</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="cdhcartype" readonly></el-input>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">接运车辆</label>
                        <div class="layui-input-inline" ref="pickupcars">
                            <el-input type="text" v-model="pickupcar" readonly></el-input>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">驾驶员</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.Cdh.STANAME" readonly></el-input>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item" v-if="isshowone">
                    <div class="layui-inline">
                        <label class="layui-form-label">是否抬尸</label>
                        <div class="layui-input-inline">
                            <el-select v-model="prpData.PRPISLIFTUP" filterable disabled>
                                <el-option label="抬尸" value="1"></el-option>
                                <el-option label="不抬尸" value="0"></el-option>
                            </el-select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">接运员</label>
                        <div class="layui-input-inline">
                            <el-select v-model="collectMember" placeholder="接运员" multiple disabled>
                                <el-option v-for="item in carriers" :key="item.value" :label="item.label" :value="item.value"></el-option>
                            </el-select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">是否特尸</label>
                        <div class="layui-input-inline">
                            <el-select v-model="prpData.PRPISSPECIAL" filterable disabled>
                                <el-option label="特尸" value="1"></el-option>
                                <el-option label="非特尸" value="0"></el-option>
                            </el-select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item" v-if="isshowtwo">
                    <div class="layui-inline">
                        <label class="layui-form-label">是否带棺</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPISCOFFINDESC" readonly></el-input>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">是否加班</label>
                        <div class="layui-input-inline">
                            <el-select v-model="prpData.Cdh.CDHISWORKOVERTIME" filterable disabled>
                                <el-option label="加班" value="1"></el-option>
                                <el-option label="不加班" value="0"></el-option>
                            </el-select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">是否值班</label>
                        <div class="layui-input-inline">
                            <el-select v-model="prpData.Cdh.CDHISCHARGE" filterable disabled>
                                <el-option label="值班" value="1"></el-option>
                                <el-option label="非值班" value="0"></el-option>
                            </el-select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline" v-if="isshowthree">
                        <label class="layui-form-label">火化炉</label>
                        <div class="layui-input-inline">
                            <el-input type="text" v-model="prpData.PRPCREMATIONDESC" readonly></el-input>
                        </div>
                    </div>
                    <div class="layui-inline" v-if="isshowthree">
                        <label class="layui-form-label" style="text-align:center;padding:0;">预约火化日期</label>
                        <!-- <div class="layui-input-inline chooseTime">
              <el-date-picker type="date" v-date v-model="prpData.PRPWORKDATE" readonly></el-date-picker>
            </div> -->
                        <div class="layui-input-inline chooseTime">
                            <el-date-picker style="width:115px;float:left;" clear-icon="null" type="date" v-date v-model="prpData.PRPCREMATIONDATEDESC" readonly></el-date-picker>
                            <el-time-picker ref="choosetime" style="width:75px;float:left" clear-icon="null" v-date v-model="prpData.PRPCREMATIONTIME" format='HH:mm' readonly></el-time-picker>
                        </div>
                    </div>
                    <div class="layui-inline" v-if="isshowfour">
                        <label class="layui-form-label" style="text-align:center;padding:0;">是否出具死亡证明</label>
                        <div class="layui-input-inline">
                            <el-select v-model="prpData.PRPISPOD" filterable disabled>
                                <el-option v-for="item in choosearray" :key="item.Value" :label="item.Text" :value="item.Value">
                                </el-option>
                            </el-select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">备注</label>
                        <div class="layui-input-inline">
                            <el-input style="width:770px" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入内容" v-model="prpData.PRPDESCRIBE" readonly>
                            </el-input>
                        </div>
                    </div>
                </div>
            </div>
            <fieldset class="layui-elem-field layui-field-title" v-if="false">
                <legend>服务项目</legend>
            </fieldset>
            <div style="margin:30px 50px;" v-if="false">
                <el-checkbox-group v-model="checkedItem" @change="ServiceItemsChange">
                    <el-checkbox v-for="value in ServiceItemsList" :label="value.SITID" :key="value.SITID" disabled>{{value.SITNAME}}</el-checkbox>
                </el-checkbox-group>
            </div>
            <div class="layui-form-item btnCenter">
                <el-button @click="infoClose">取消</el-button>
            </div>
        </sweet-modal>
        <printPdf ref="prints"></printPdf>
        <carSendNewMain ref="carSendNewMain"></carSendNewMain>
        <carSendMain ref="carSendMain"></carSendMain>
    </div>
</template>

<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";
.el-button + .el-button {
    margin-left: 0;
}
</style>
<script>
import apiBase from "@/api/apiBase.js";
import sweetModal from "@/components/sweetModal";
import printPdf from "@/components/Pdf/Print";
import { manage } from "@/mixins/managePage.js";
import { formatDate, timeStringToDate } from "@/utils/date.js";
import { PRPORDER } from "@/const/orderConst.js";
import { ORDER } from "@/const/orderConst.js";
import carSendNewMain from "../server/carSendNewMain";
import carSendMain from "../server/carSendMain";
import {
  MessageBox,
  Message
} from 'element-ui'
const onecar = "普通车";
const twocar = "高档车";
const threecar = "自送";
const fourcar = "加长车";
export default {
    mixins: [manage],
    data() {
        return {
            REGRELATIONOptions: [],
            carShow: true, //预约新增是否显示默认车辆
            carriers: [],
            cauinfo: [],
            cause: [],
            issendcar: null, //是否显示保存按钮
            issendcarone: false, //控制派车登记按钮是否显示
            isshowcar: null,
            isshowone: null,
            isshowtwo: null,
            isshowthree: null,
            isshowfour: null,
            PRPNO: null,
            isShowyy: null, //余姚个性化
            REGCAUSA: null,
            REGCAUSASON: null,
            order: null,
            prpid:null,
            maxWidth: 1100,
            title: null,
            addsInfo: {},
            commonAddr: [],
            copycommonAddr: [],
            feeders: [],
            isdisable: false,

            timeDefaultShow: [new Date(0)],

            //编码
            carLics: [],
            pickupcardatas: [],
            drivers: [],
            isdg: [],
            hhldata: [],
            preSitDesc: null,
            serviceListType: [],
            sexType: [],
            ServiceItemsList: [],
            checkedItem: [],

            choosearray: [
                { Value: "B", Text: "是" },
                { Value: "A", Text: "否" }
            ],
            prpData: {
                PRPID: null,
                PRPNO: null,
                PRPLINKMAN: null,
                PRPDEADAGE: null,
                PRPDEADSEX: null,
                PRPLINKPHONE: null,
                PRPRELATION: "",
                PRPORIGINALCALL: null,
                PRPCALLDATE: null,
                PRPDEATHDATE: null,
                PRPDEADNAME: null,
                PRPORIGINALCALL: null,
                PRPYITIQX: null,
                PRPDESCRIBE: "",
                PRPCORPSEADDRESS: null,
                PRPADDID: "",
                PRPLINID: "",
                PRPMEMID: "",
                PRPFEEDERCATEGORY: "",
                PRPWORKDATE: "",
                PRPCREMATIONDATE: null,
                PRPWORKTIME: null,
                PRPCREMATIONTIME: null,
                PRPPROCESSINGUNIT: null,
                PRPSPARELINKMAN: null,
                PRPSPARELINKPHONE: null,
                // PRPFEEDERCATEGORY:'',
                PRPLINSTRTDATE: null,
                PRPLINSTRTIME: null,
                PRPMEMSTRDATE: null,
                PRPMENSTRTIME: null,
                PRPCREMATION: null,
                PRPISCOFFIN: null,
                PRPISPOD: null, //是否出具死亡证明
                // 是否特尸
                PRPISSPECIAL: "0",
                // 是否抬尸
                PRPISLIFTUP: "0",
                //服务项目预约信息
                Psts: [],
                //派车信息
                Cdh: {    
                    CDHCARID: null,
                    CARLIC: null,
                    CARCODNAME: null,
                    CARCODNAMEDESC: null,
                    CDHDRIVER: null,
                    STANAME: null,
                    // 是否值班人员
                    CDHISCHARGE: "0",
                    // 是否加班
                    CDHISWORKOVERTIME: "0",
                    // 接运员
                    List_CarryArr: []
                }
            },
            regDataEexend: {
                leasetime: null,
                appointmenttime: null
            },
            cdhcartype: null,
            pickupcar: null,
            collectMember: []
        };
    },
    methods: {
        open(order, id) {
            // this.isdisable = id;
            this.order = order;
            this.prpid = id;
            this.maxHeight = window.innerHeight - 240;
            //清理数据
            // this.prpData.PRPCALLDATE=new Date();
            this.getSzgxType()
            switch (this.order) {
                case "义乌新增":
                    this.dataRepeat(); //数据重置
                    this.title = "电话预约新增";
                    this.initSelectData(); //初始化下拉框
                    this.issendcars();
                    this.issendcarone = false;
                    this.isdisable = false;
                    this.prpData.PRPWORKDATE = new Date(); //接尸时间
                    this.prpData.PRPDEATHDATE = new Date(); //死亡时间
                    // this.prpData.PRPCREMATIONDATE = new Date();
                    this.regDataEexend.leasetime = new Date();
                    this.regDataEexend.appointmenttime = new Date();
                    this.$refs.dialog.open();
                    break;
                case "义乌修改":
                    this.title = "电话预约修改";
                    this.initSelectData();
                    this.dataInfo(id);
                    this.issendcarone = true;
                    this.issendcar = false;
                    this.isdisable = false;
                    this.$refs.dialog.open();
                    break;
                case "义乌详情":
                    this.initSelectData(); //初始化下拉框  宁波 电弧记录死亡原因显示
                    this.title = "电话预约详情";
                    this.dataRepeat();
                    this.dataInfo(id);
                    this.$refs.info.open();
                    break;
                default:
            }
        },
        // 年龄只能输正整数
        check(val){
            this.prpData.PRPDEADAGE = this.checkNumber(val.toString());
        },
        //只能输入正整数
        checkNumber(value) {
            value = value.replace(/\D/g, "").replace(/^0+(?=\d)/, "");
            if (value !== "") {
            if (value.substr(0, 1) === "0" && value.length === 2) {
                value = value.substr(1, value.length);
            }
            } else {
            value = 0;
            }
            return value;
        },
        //下拉框设置拼音简码跳出
        PinyinMatch(val) {
            const PinyinMatch = require("pinyin-match");
            if (val) {
                var result = [];
                this.copycommonAddr.forEach(i => {
                    var m = PinyinMatch.match(i.CodeName, val);
                    if (m) {
                        result.push(i);
                    }
                });
                this.commonAddr = result;
            } else {
                this.commonAddr = this.copycommonAddr;
            }
        },
        pickupcardata(val) {
     
            switch (val) {
                case onecar: //普通车
                    for (var i = 0; i < this.carLics.length; i++) {
                        if (this.carLics[i].label == onecar) {
                            this.pickupcardatas = this.carLics[i].children;
                            // return;
                        }
                    }
                    if (this.pickupcardatas.length == 0) {
                        this.pickupcar = null;
                        this.prpData.Cdh.CDHDRIVER = null;
                    } else {
                        if (this.carShow == true) {
                            this.pickupcar = null;
                        } else {
                            if(this.order==ORDER.ADD){
                                this.pickupcar = this.pickupcardatas[0].label; //3.在这里会给pickupcar赋默认值，所以给这句话加一个判断，让他只有在新增的时候去执行,记着下面的也要加判断啊
                            }
                            if (this.pickupcardatas[0].CARDRIVER != "") {
                                this.prpData.Cdh.CDHDRIVER = this.pickupcardatas[0].CARDRIVER;
                            } else {
                                this.prpData.Cdh.CDHDRIVER = null;
                            }
                        } //加的判断
                       
                    }
                    break;
                case twocar: //高档车
                    for (var i = 0; i < this.carLics.length; i++) {
                        if (this.carLics[i].label == twocar) {
                            this.pickupcardatas = this.carLics[i].children;
                            // return;
                        }
                    }
                    // this.pickupcardatas = this.carLics[1].children;
                    if (this.pickupcardatas.length == 0) {
                        this.pickupcar = null;
                        this.prpData.Cdh.CDHDRIVER = null;
                    } else {
                        if(this.order==ORDER.ADD){
                        this.pickupcar = this.pickupcardatas[0].label; //是这一句
                        }
                        if (this.pickupcardatas.CARDRIVER != "") {
                         
                            this.prpData.Cdh.CDHDRIVER = this.pickupcardatas[0].CARDRIVER; 
                            
                        } else {
                            this.prpData.Cdh.CDHDRIVER = null;
                        }
                    }
                    break;
                case threecar: //自送车
                    for (var i = 0; i < this.carLics.length; i++) {
                        if (this.carLics[i].label == threecar) {
                            this.pickupcardatas = this.carLics[i].children;
                            // return;
                        }
                    }
                    // this.pickupcardatas = this.carLics[2].children;
                    if (this.pickupcardatas.length == 0) {
                        this.pickupcar = null;
                        this.prpData.Cdh.CDHDRIVER = null;
                    } else {
                        if(this.order==ORDER.ADD){
                        this.pickupcar = this.pickupcardatas[0].label;
                        }
                        if (this.pickupcardatas.CARDRIVER != "") {
                            this.prpData.Cdh.CDHDRIVER = this.pickupcardatas[0].CARDRIVER;
                        } else {
                            this.prpData.Cdh.CDHDRIVER = null;
                        }
                    }
                    break;
                case fourcar: //加长车 宁波
                    for (var i = 0; i < this.carLics.length; i++) {
                        if (this.carLics[i].label == fourcar) {
                            this.pickupcardatas = this.carLics[i].children;
                            // return;
                        }
                    }
                    if (this.pickupcardatas.length == 0) {
                        this.pickupcar = null;
                        this.prpData.Cdh.CDHDRIVER = null;
                    } else {
                        if(this.order==ORDER.ADD){
                        this.pickupcar = this.pickupcardatas[0].label;
                        }
                        if (this.pickupcardatas.CARDRIVER != "") {
                            this.prpData.Cdh.CDHDRIVER = this.pickupcardatas[0].CARDRIVER;
                        } else {
                            this.prpData.Cdh.CDHDRIVER = null;
                        }
                    }
                    break;
                default:
            }
        },
        dirverchange(val) {
            for (var i = 0; i < this.pickupcardatas.length; i++) {
                if (this.pickupcardatas[i].label == val) {
                    if(JSON.stringify(this.prpData.Cdh) == '{}'){
                        this.prpData.Cdh = {
                            CDHDRIVER: this.pickupcardatas[i].CARDRIVER
                        }
                    }
                }
            }
        },
        //获取死亡原因
        getCausa() {
            let data = {};
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Code.GetCausa,
                res => {
                    let caudata = res.data.content;
                    this.cause = caudata.map(item => ({
                        label: item.CAENAME,
                        value: item.CAEID,
                        children: item.Caus.map(itemCau => ({
                            label: itemCau.CAUNAME,
                            value: itemCau.CAUID
                        }))
                    }));
                    // 默认死亡原因
                    // if (this.cause[0] && this.cause[0].children[0])
                    //     this.cauinfo = [
                    //         this.cause[0].value,
                    //         this.cause[0].children[0].value
                    //     ];
                }
            );
        },
        NameBlur(val){
            let data={};
            if(this.order=='义乌新增'){
            data = {
                PRPDEADNAME:val,
            }
            }else{
            data = {
                PRPDEADNAME:val,
                PRPID:this.prpid
            }
            }
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Reserve.QueryReserveByName,
                res => {}
            );
        },
        //初始化下拉框数据
        initSelectData() {
            //初始化下拉框数据
            this.getSexType();
            this.getServiceItems();
            this.getCar();
            this.getCommonAddr();
            this.getCausa();
            this.getServiceTypes();
            this.getDrivers();
            this.getFeeders();
            this.GetIsCoffinStatus();
            this.GetCreationStatus();
            this.getCarriers();
        },
        //提交
        submit() {
            switch (this.order) {
                case PRPORDER.ADD:
                    this.dataAdd();
                    break;
                case "义乌新增":
                    this.dataAdd();
                    break;
                case PRPORDER.MODIFY:
                    this.dataModify();
                    break;
                case "义乌修改":
                    this.dataModify();
                    break;
                case PRPORDER.DELETE:
                    break;
                case PRPORDER.INFO:
                    break;
                default:
            }
        },
        //自定义筛选
        chaFilter(val) {
            const PinyinMatch = require("pinyin-match");
            if (val) {
                var result = [];
                this.allCharge.forEach(i => {
                    var m = PinyinMatch.match(i.CodeName, val);
                    if (m) {
                        result.push(i);
                    }
                });
                this.sexType = result;
            } else {
                this.sexType = this.allCharge;
            }
        },
        closeDialog() {
            if (this.order === "义乌新增" || this.order === "义乌修改")
                this.$refs.dialog.close();
            else if (this.order === PRPORDER.INFO) this.$refs.info.close();
        },
        //保存
        Preservation() {
            for (var i in this.pickupcardatas) {
                if (this.pickupcardatas[i].label == this.pickupcar) {
                    this.prpData.Cdh.CDHCARID = this.pickupcardatas[i].value;
                }
            }
            // 死亡日期不能大于火化日期
            if (
                this.prpData.PRPDEATHDATE != null && this.prpData.PRPCREMATIONDATE != null&& this.prpData.PRPDEATHDATE != "" && this.prpData.PRPCREMATIONDATE != ""
            ) {
                var deadtime = formatDate(this.prpData.PRPDEATHDATE,'yyyyMMdd');
                var huohuatime = formatDate(this.prpData.PRPCREMATIONDATE,'yyyyMMdd');
                if (deadtime > huohuatime) {
                    this.$message({
                        type: "error",
                        message: "死亡日期不能大于火化日期！"
                    });
                    return;
                }
            }
            let Data = JSON.parse(JSON.stringify(this.prpData));
            if (Data.PRPLINID == "") {
                Data.PRPLINSTRTDATE = "";
                Data.PRPLINSTRTIME = "";
            } else {
                Data.PRPLINSTRTDATE = formatDate(
                    this.regDataEexend.leasetime,
                    "yyyyMMdd"
                );
                Data.PRPLINSTRTIME = formatDate(
                    this.regDataEexend.leasetime,
                    "hhmmss"
                );
            }
            if (Data.PRPMEMID == "") {
                Data.PRPMEMSTRDATE = "";
                Data.PRPMENSTRTIME = "";
            } else {
                Data.PRPMEMSTRDATE = formatDate(
                    this.regDataEexend.appointmenttime,
                    "yyyyMMdd"
                );
                Data.PRPMENSTRTIME = formatDate(
                    this.regDataEexend.appointmenttime,
                    "hhmmss"
                );
            }
            Data.PRPCALLDATE = formatDate(Data.PRPCALLDATE, "yyyyMMdd");
            Data.PRPDEATHDATE = formatDate(Data.PRPDEATHDATE, "yyyyMMdd");
            Data.PRPWORKDATE = formatDate(Data.PRPWORKDATE, "yyyyMMdd");
            Data.PRPCREMATIONDATE = formatDate(
                Data.PRPCREMATIONDATE,
                "yyyyMMdd"
            );
            if (Data.PRPWORKTIME != null) {
                Data.PRPWORKTIME = formatDate(Data.PRPWORKTIME, "hhmm") + "00";
            }
            if (Data.PRPCREMATIONTIME != null) {
                Data.PRPCREMATIONTIME =
                    formatDate(Data.PRPCREMATIONTIME, "hhmm") + "00";
            }
            Data.PRPCAUSA = this.cauinfo[0];
            Data.PRPCAUSASON = this.cauinfo[1];
            Data.Cdh.STANAME = this.prpData.Cdh.STANAME;
            Data.Cdh.list_CarryArr = this.collectMember;
            apiBase.DoService(
                Data,
                apiBase.getApiAdress().Reserve.CreatePhoneReserve,
                res => {
                    this.$message({
                        type: "success",
                        message: "新增成功!"
                    });
                    this.refreshData();
                    this.isdisable = true;
                    this.issendcarone = true;
                    this.PRPNO = res.data.content.PRPNO;
                    this.addsInfo = res.data.content;
                },
                res => {
                    this.$message.error(res.data.msg);
                }
            );
        },
        //跳转派车登记
        Gosendcar() {
            this.$refs.carSendNewMain.open("义乌派车", this.PRPNO);
        },
        // 打印派车单
        pdfpaicar() {
            this.$refs.prints.open("打印派车单", this.addsInfo.PRPID, null);
        },
        // 获取逝者关系
        getSzgxType() {
            apiBase.DoService(
                {},
                apiBase.getApiAdress().Code.GetSzgxType,
                res => {
                    let SzgxType = res.data.content;
                    this.REGRELATIONOptions = SzgxType.map(item => ({
                        label: item.CodeName,
                        value: item.CodeValue
                    }));
                }
            );
        },
        //获取常用地址
        getCommonAddr() {
            let data = {};
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Code.GetCommonAddress,
                res => {
                    this.commonAddr = res.data.content;
                    this.copycommonAddr = res.data.content;
                }
            );
        },
        //接运类别
        getFeeders() {
            let data = {};
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Code.GetFeederCategory,
                res => {
                    this.feeders = res.data.content;
                }
            );
        },

        //获取性别
        getSexType() {
            let data = {};
            apiBase.DoService(data, apiBase.getApiAdress().Code.GetSex, res => {
                this.allCharge = res.data.content;
                this.sexType = res.data.content;
            });
        },

        //获取服务类型
        getServiceTypes() {
            let data = {};
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Code.GetYitiqx,
                res => {
                    this.serviceListType = res.data.content;
                    this.prpData.PRPYITIQX = this.serviceListType[0].CodeValue;
                }
            );
        },
        //获取服务项目
        getServiceItems() {
            let data = {};
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Reserve.QueryServiceItem,
                res => {
                    let serviceList = res.data.content;
                    this.ServiceItemsList = [];
                    for (var i in serviceList) {
                        this.ServiceItemsList.push.apply(
                            this.ServiceItemsList,
                            serviceList[i].Sits
                        );
                    }
                }
            );
        },
        //获取预约火化炉类型
        GetCreationStatus() {
            let data = {};
            apiBase.DoService(
                data,
                // apiBase.getApiAdress().Reserve.GetPrpCreationStatus,
                apiBase.getApiAdress().Code.GetCremationType,
                res => {
                    let creTypeData = res.data.content,
                        legendsCreData = creTypeData.map(item => ({
                            Text: item.CodeName,
                            Value: item.CodeValue
                        }));
                    this.hhldata = legendsCreData;
                    this.hhldata.unshift({ Text: "不选择", Value: "" });
                }
            );
        },
        //获取预约是否带棺
        GetIsCoffinStatus() {
            let data = {};
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Reserve.GetPrpIsCoffinStatus,
                res => {
                    this.isdg = res.data.content;
                    // let serviceList = res.data.content;
                    // this.ServiceItemsList = [];
                    // for (var i in serviceList) {
                    //   this.ServiceItemsList.push.apply(
                    //     this.ServiceItemsList,
                    //     serviceList[i].Sits
                    //   );
                    // }
                }
            );
        },
        //获取车辆信息
        getCar() {
            let data = {};
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Car.QueryCarByType,
                res => {
                    let cardata = res.data.content;
                    let legendsCarData = cardata.map(item => ({
                        label: item.CodeName,
                        value: item.CodeValue,
                        children: item.list_Cars.map(caritem => ({
                            label: caritem.CARLIC,
                            value: caritem.CARID,
                            CARDRIVER: caritem.CARDRIVER
                        }))
                    }));
                    this.carLics = legendsCarData;
                    if (this.carLics.length > 0) {
                        if (this.carShow == true) {
                            this.cdhcartype = this.carLics[0].label; //车辆类型
                            this.pickupcar = [];
                        } else {
                            this.cdhcartype = this.carLics[0].label; //车辆类型
                            this.pickupcar = this.carLics[0].children[0].label; //接运车辆
                        }
                    } else {
                        this.cdhcartype = "";
                        this.pickupcar = "";
                    }
                    this.pickupcardata(this.cdhcartype);
                }
            );
        },
        //获取司机
        getDrivers() {
            let data = {};
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Staff.QueryDriver,
                res => {
                    let driverData = res.data.content,
                        legendsDrivers = driverData.map(item => ({
                            label: item.STANAME,
                            value: item.STAID
                        }));
                    this.drivers = legendsDrivers;
                }
            );
        },
        //获取接运员
        getCarriers() {
            let data = {};
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Staff.QueryCarry,
                res => {
                    let carryData = res.data.content,
                        legendsCarriers = carryData.map(item => ({
                            label: item.STANAME,
                            value: item.STAID
                        }));
                    this.carriers = legendsCarriers;
                }
            );
        },
        //登记新增
        dataAdd() {
            
            for (var i in this.pickupcardatas) {
                if (this.pickupcardatas[i].label == this.pickupcar) {
                    this.prpData.Cdh.CDHCARID = this.pickupcardatas[i].value;
                }
            }
            let Data = JSON.parse(JSON.stringify(this.prpData));
            // 死亡日期不能大于火化日期
            if (
                this.prpData.PRPDEATHDATE != null && this.prpData.PRPCREMATIONDATE != null&& this.prpData.PRPDEATHDATE != "" && this.prpData.PRPCREMATIONDATE != ""
            ) {
                var deadtime = formatDate(this.prpData.PRPDEATHDATE,'yyyyMMdd');
                var huohuatime = formatDate(this.prpData.PRPCREMATIONDATE,'yyyyMMdd');
                if (deadtime > huohuatime) {
                    this.$message({
                        type: "error",
                        message: "死亡日期不能大于火化日期！"
                    });
                    return;
                }
            }
            if (Data.PRPLINID == "") {
                Data.PRPLINSTRTDATE = "";
                Data.PRPLINSTRTIME = "";
            } else {
                Data.PRPLINSTRTDATE = formatDate(
                    this.regDataEexend.leasetime,
                    "yyyyMMdd"
                );
                Data.PRPLINSTRTIME = formatDate(
                    this.regDataEexend.leasetime,
                    "hhmmss"
                );
            }
            if (Data.PRPMEMID == "") {
                Data.PRPMEMSTRDATE = "";
                Data.PRPMENSTRTIME = "";
            } else {
                Data.PRPMEMSTRDATE = formatDate(
                    this.regDataEexend.appointmenttime,
                    "yyyyMMdd"
                );
                Data.PRPMENSTRTIME = formatDate(
                    this.regDataEexend.appointmenttime,
                    "hhmmss"
                );
            }
            Data.PRPCALLDATE = formatDate(Data.PRPCALLDATE, "yyyyMMdd");
            Data.PRPDEATHDATE = formatDate(Data.PRPDEATHDATE, "yyyyMMdd");
            Data.PRPWORKDATE = formatDate(Data.PRPWORKDATE, "yyyyMMdd");
            Data.PRPCREMATIONDATE = formatDate(
                Data.PRPCREMATIONDATE,
                "yyyyMMdd"
            );
            if (Data.PRPWORKTIME != null) {
                Data.PRPWORKTIME = formatDate(Data.PRPWORKTIME, "hhmm") + "00";
            }
            if (Data.PRPCREMATIONTIME != null) {
                Data.PRPCREMATIONTIME =
                    formatDate(Data.PRPCREMATIONTIME, "hhmm") + "00";
            }
            Data.PRPCAUSA = this.cauinfo[0];
            Data.PRPCAUSASON = this.cauinfo[1];
            Data.Cdh.STANAME = this.prpData.Cdh.STANAME;
            Data.Cdh.list_CarryArr = this.collectMember;
            Data.CDHDRIVER = this.prpData.Cdh.CDHDRIVER;
            apiBase.DoService(
                Data,
                apiBase.getApiAdress().Reserve.CreatePhoneReserve,
                res => {
                    this.addsInfo = res.data.content;
                    this.$confirm("是否打印派车单?", "新增成功", {
                        confirmButtonText: "打印",
                        cancelButtonText: "不打印",
                        type: "warning"
                    })
                        .then(() => {
                            this.$refs.prints.open(
                                "打印派车单",
                                this.addsInfo.PRPID,
                                null
                            );
                        })
                        .catch(() => {
                            this.$message({
                                type: "success",
                                message: "新增成功!"
                            });
                        });
                    this.refreshData();
                    this.$refs.dialog.close();
                },
                res => {
                    this.$message.error(res.data.msg);
                }
            );
        },
        //登记修改
        dataModify() {    
            for (var i in this.pickupcardatas) {
                if (this.pickupcardatas[i].label == this.pickupcar) {
                    this.prpData.Cdh.CDHCARID = this.pickupcardatas[i].value;
                }
            }
            // 死亡日期不能大于火化日期
            if (
                this.prpData.PRPDEATHDATE != null &&this.prpData.PRPCREMATIONDATE != null&& this.prpData.PRPDEATHDATE != "" && this.prpData.PRPCREMATIONDATE != ""
            ) {
             var deadtime = formatDate(this.prpData.PRPDEATHDATE,'yyyyMMdd');
             var huohuatime = formatDate(this.prpData.PRPCREMATIONDATE,'yyyyMMdd');
                if (deadtime > huohuatime) {
                    this.$message({
                        type: "error",
                        message: "死亡日期不能大于火化日期！"
                    });
                    return;
                }
            }
            let Data = JSON.parse(JSON.stringify(this.prpData));
            if (Data.PRPFEEDERCATEGORY == null) {
                Data.PRPFEEDERCATEGORY = "";
            }
            if (Data.PRPLINID == null) {
                Data.PRPLINID = "";
            }
            if (Data.PRPMEMID == null) {
                Data.PRPMEMID = "";
            }
            if (Data.PRPLINID == "") {
                Data.PRPLINSTRTDATE = "";
                Data.PRPLINSTRTIME = "";
            } else {
                Data.PRPLINSTRTDATE = formatDate(
                    this.regDataEexend.leasetime,
                    "yyyyMMdd"
                );
                Data.PRPLINSTRTIME = formatDate(
                    this.regDataEexend.leasetime,
                    "hhmmss"
                );
            }
            if (Data.PRPMEMID == "") {
                Data.PRPMEMSTRDATE = "";
                Data.PRPMENSTRTIME = "";
            } else {
                Data.PRPMEMSTRDATE = formatDate(
                    this.regDataEexend.appointmenttime,
                    "yyyyMMdd"
                );
                Data.PRPMENSTRTIME = formatDate(
                    this.regDataEexend.appointmenttime,
                    "hhmmss"
                );
            }
            Data.PRPCALLDATE = formatDate(Data.PRPCALLDATE, "yyyyMMdd");
            Data.PRPDEATHDATE = formatDate(Data.PRPDEATHDATE, "yyyyMMdd");
            Data.PRPWORKDATE = formatDate(Data.PRPWORKDATE, "yyyyMMdd");
            Data.PRPCREMATIONDATE = formatDate(
                Data.PRPCREMATIONDATE,
                "yyyyMMdd"
            );
            if (Data.PRPWORKTIME != null) {
                Data.PRPWORKTIME = formatDate(Data.PRPWORKTIME, "hhmm") + "00";
            }
            if (Data.PRPCREMATIONTIME != null) {
                Data.PRPCREMATIONTIME =
                    formatDate(Data.PRPCREMATIONTIME, "hhmm") + "00";
            }
            Data.PRPCAUSA = this.cauinfo[0];
            Data.PRPCAUSASON = this.cauinfo[1];
            Data.Cdh.STANAME = this.prpData.Cdh.STANAME;
            Data.Cdh.list_CarryArr = this.collectMember;
            apiBase.DoService(
                Data,
                apiBase.getApiAdress().Reserve.ModifyPhoneReserve,
                res => {
                    this.$refs.dialog.close();
                    this.$message({
                        type: "success",
                        message: "修改成功!"
                    });
                    this.refreshData();
                }
            );
        },
        //登记详情
        dataInfo(id) {
            let Data = {
                PRPID: id
            };
            apiBase.DoService(
                Data,
                apiBase.getApiAdress().Reserve.DetailPhoneReserve,          
                res => {
                    if(res.data.content.Cdh == null) res.data.content.Cdh = {};
                    this.prpData = res.data.content;
                    // console.log(this.prpData);
                    this.PRPNO = res.data.content.PRPNO;
                    this.addsInfo = res.data.content;
                     
                    // this.prpData.PRPDEATHDATE = dateStringToDate(//死亡日期
                    //     this.prpData.PRPDEATHDATE
                    // );
                    this.prpData.PRPDEATHDATE =
                        res.data.content.PRPDEATHDATEDESC;
                    this.prpData.PRPCREMATIONDATE =
                        res.data.content.PRPCREMATIONDATEDESC;
                    this.regDataEexend.leasetime = timeStringToDate(
                        this.prpData.PRPLINSTRTIME,
                        this.prpData.PRPLINSTRTDATE
                    );
                    this.regDataEexend.appointmenttime = timeStringToDate(
                        this.prpData.PRPMENSTRTIME,
                        this.prpData.PRPMEMSTRDATE
                    );
                    this.prpData.PRPWORKTIME = timeStringToDate(
                        this.prpData.PRPWORKTIME
                    );
                    this.prpData.PRPCREMATIONTIME = timeStringToDate(
                        this.prpData.PRPCREMATIONTIME
                    );
                   
                    //-----之前注释了
                    if (this.order == '义乌修改') {
                        this.cdhcartype = this.prpData.Cdh.CARCODNAMEDESC;
                        this.pickupcardata(this.cdhcartype);  //1.调这个方法会把下面的pickupcar冲突掉                        
                        setTimeout(() => {
                            this.pickupcar = this.prpData.Cdh.CARLIC; //2.就是这句话会被冲掉 ，所以要在this.pickupcardata()这个方法中加判断
                        }, 200);      
                    } else {
                        if(this.prpData.Cdh == {}) return;
                        this.cdhcartype = this.prpData.Cdh.CARCODNAMEDESC;
                        this.pickupcar = this.prpData.Cdh.CARLIC;
                    }
                    // this.pickupcar = this.prpData.Cdh.CARLIC;

                    this.collectMember = res.data.content.Cdh.list_CarryArr;

                    this.getServiceItems(); //获取服务项目   CDHDRIVER
                    //-----  CDHDRIVER
                    if(this.prpData.Cdh != null){
                        this.prpData.Cdh.CDHDRIVER = this.prpData.Cdh.CDHDRIVER;
                    }else{
                        this.prpData.Cdh = {
                            CDHDRIVER: null
                        }
                    };
                    if (!this.prpData.Psts) {
                        this.prpData.Psts = [];
                    }
                    if (!this.prpData.Cdh) {
                        this.prpData.Cdh = {
                            CDHCARID: null,
                            CDHDRIVER: null
                        };
                    }
                    let psts = res.data.content.Psts;
                    for (var i in psts) {
                        this.checkedItem.push(psts[i].PSTSITID);
                    }
                    this.cauinfo = [
                        this.prpData.PRPCAUSA,
                        this.prpData.PRPCAUSASON
                    ];
                }
            );
        },
        selectAddr() {
            this.prpData.PRPCORPSEADDRESS = this.prpData.PRPADDID + "";
        },
        //服务项目选择
        ServiceItemsChange(serItems) {
            let pstsList = [];
            for (var i in serItems) {
                var pst = {
                    PSTSITID: serItems[i],
                    PSTNUMBER: 1
                };
                this.preSitDesc += pstsList.push(pst);
            }
            this.prpData.Psts = pstsList;
        },
        //服务项目选择
        changItem(el, val) {
            var staname = val.SITNAME + "。";
            if (el) {
                this.prpData.PRPDESCRIBE += staname;
            } else {
                this.prpData.PRPDESCRIBE = this.prpData.PRPDESCRIBE.replace(
                    staname,
                    ""
                );
            }
        },
        //数据重置
        dataRepeat() {
            this.pcrFirst = false;
            this.preFirst = false;
            this.checkedItem = [];
            this.pickupcardatas = [];
            this.cauinfo = [];
            this.cdhcartype = null;
            this.pickupcar = null;
            Object.assign(this.$data.prpData, this.$options.data().prpData);
            this.prpData.PRPCALLDATE = formatDate(new Date(), "yyyy-MM-dd");
            this.regDataEexend.leasetime = null;
            this.regDataEexend.appointmenttime = null;
            this.collectMember = [];
        },
        issendcars() {
            let data = {};
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Param.GetPrpIsSendCar,
                res => {
                    this.issendcar = res.data.content; //是否显示保存按钮
                }
            );
        },
        refreshData() {
            this.$emit("refreshData");
        }
    },
    created() {
        let data = {};
        apiBase.DoService(
            data,
            apiBase.getApiAdress().Param.GetIsShowOutOfTime,
            res => {
                this.isShowyy = res.data.content; //余姚个性化
            }
        );
        //预约新增是否显示默认车辆
        apiBase.DoService(
            {},
            apiBase.getApiAdress().Param.GetIsShowDefultCar,
            res => {
                this.carShow = res.data.content;
            }
        );
        apiBase.DoService(
            data,
            apiBase.getApiAdress().Param.GetPrpShowProgram,
            res => {
                let showprp = res.data.content; //预约显示项
                if (showprp.indexOf("A") > -1) {
                    this.isshowcar = true;
                }
                if (showprp.indexOf("B") > -1) {
                    this.isshowone = true;
                }
                if (showprp.indexOf("C") > -1) {
                    this.isshowtwo = true;
                }
                if (showprp.indexOf("D") > -1) {
                    this.isshowthree = true;
                }
                if (showprp.indexOf("E") > -1) {
                    this.isshowfour = true;
                }
            }
        );
    },
    components: {
        sweetModal,
        printPdf,
        carSendNewMain,
        carSendMain
    },
    watch: {
        cauinfo: function(val) {
            this.REGCAUSA = val[0];
            this.REGCAUSASON = val[1];
        },
        "regDataEexend.leasetime": function(val) {
            this.prpData.PRPLINSTRTDATE = formatDate(val, "yyyyMMdd");
            this.prpData.PRPLINSTRTIME = formatDate(val, "hhmmss");
        },
        "regDataEexend.appointmenttime": function(val) {
            this.prpData.PRPMEMSTRDATE = formatDate(val, "yyyyMMdd");
            this.prpData.PRPMENSTRTIME = formatDate(val, "hhmmss");
        }
    }
};
</script>

